import sys
from PyQt5.QtWidgets import QApplication,QWidget
from PyQt5.QtCore import *


class Window(QWidget):
    def __init__(self,game):
        super().__init__()
        self.game=game
        self.a=0
        self.w=0
        self.s=0
        self.d=0
        self.j=0

    def initUI(self):
        self.setGeometry(100,100, 300, 200)
        self.setFixedWidth(300)
        self.setFixedHeight(300)
        self.setWindowTitle('')
        self.show()
        


    def keyPressEvent(self, event):

        if(event.key() == Qt.Key_W):
            self.w=1
            
        if(event.key() == Qt.Key_S):
            self.s=1

        if(event.key() == Qt.Key_A):
            self.a=1
        
        if(event.key() == Qt.Key_D):
            self.d=1
        
        if(event.key() == Qt.Key_J):
            self.j=1
            
        self.game.set_keys(self.w,self.a,self.s,self.d,self.j)

            
    def keyReleaseEvent(self,event):
        if(event.key() == Qt.Key_W):
            self.w=0
            
        if(event.key() == Qt.Key_S):
            self.s=0

        if(event.key() == Qt.Key_A):
            self.a=0
        
        if(event.key() == Qt.Key_D):
            self.d=0
        
        if(event.key() == Qt.Key_J):
            self.j=0

        self.game.set_keys(self.w,self.a,self.s,self.d,self.j)






def create_player_con(game):
    app = QApplication(sys.argv)
    window = Window(game)
    sys.exit(app.exec_())


